index_app.controller("member_recharge_edit", function ($scope,$http,$timeout) {

    $('#myModal').modal('show');
    $scope.vipTypeArry=['普通会员','白银会员','至尊会员'];
    $scope.payMethod=['现金','支付宝','微信'];
    $http.post("activity/selectAll").then(function(response){
         //数据源
          $scope.activityList = response.data;
    });
    $http.post("stmUsr/selectAll").then(function(response){
      	//数据源
      	$scope.stmUsrList = response.data;
      });

    $scope.searchVipNum = function(){
        console.log($scope.vipInputNum);
         $http.post("menberInfo/selectByVipNum?vipNum="+$scope.vipInputNum).then(function(response){
            	//数据源
            	$scope.memberRecharge = response.data;
                $scope.memberRecharge.amount = "";
            	$scope.prewActivAmount = $scope.memberRecharge.activityAmount;
            	$scope.memberRecharge.activityAmount = "";
            	$('#myModal').modal('hide');
            });
    }





	//用户信息修改页面中保存操作
	$scope.memberRechargeUpdate = function(memberRecharge){
           memberRecharge.balance = $scope.memberRecharge.balance*1 + memberRecharge.amount*1 + memberRecharge.activityAmount*1;
           memberRecharge.activityAmount = $scope.prewActivAmount*1 + memberRecharge.activityAmount*1;
            console.log( memberRecharge);
        		$http({
        			method  : 'POST',
        			url     : 'menberInfo/updateMmberSaving?comment='+memberRecharge.comment,
        			data    : memberRecharge,//传递真个对象到后台
        		}).success(function(data) {
        			if(data == 1){
        				//添加保存标题样式
        				$scope.title = '<h4 class="easyDialog_title" id="easyDialogTitle"><i class="icon-ok green"></i> <a href="javascript:void(0)" title="关闭窗口" class="close_btn" id="closeBtn">&times;</a>保存</h4>';
        				//保存成功内容
        				$scope.toolTip = "保存成功";
        				//弹窗
        				toolTipDialog();
        				$scope.success = true;

        			} else {
        				$scope.title = "保存";
        				$scope.toolTip = "保存失败";
        				toolTipDialog();
        			}
        		});
	};

	function toolTipDialog(){
    		easyDialog.open({
    			container : {
    				header : $scope.title,
    				content : $scope.toolTip,
    				yesFn : $scope.toolFn,
    				noFn : false
    			},
    			fixed : false
    		});
    	}
    	//弹窗中确定按钮事件
        	$scope.toolFn = function(){
        		if( $scope.success){//成功
        			window.location.href="#member_management_list";
        		}
        		return true;
        	}

})